package com.weiiew.backend.operation;

import com.weiiew.backend.operationUtils.MouseCode;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.awt.*;

/**
 * @Description
 * @Author 魏锴
 * @Date 2025/4/26
 */
@Setter
@Getter
@ToString
@AllArgsConstructor
public class MousePress extends ComputerOperation {
    private static final long serialVersionUID = 121204894516L; // 添加 serialVersionUID
    private final MouseCode button;

    public MousePress(MouseCode button, long timestamp) {
        this.button = button;
        super.setTimestamp(timestamp);
    }

    public MousePress(long timestamp, String desc) {
        super.setTimestamp(timestamp);
        this.button = MouseCode.valueOf(desc);
    }

    @Override
    public String toDescriptionString() {
        return String.format("mp@%d@%s",
                this.getTimestamp(), button.name());
    }

    @Override
    public void execute(Robot robot) {
        robot.mousePress(button.getRobotMask());
    }
}
